package projet.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name="client")
@NamedQueries({
    @NamedQuery(name="Client.findAll", query="SELECT c FROM Client c ORDER BY c.id"),
    @NamedQuery(name="Client.findById", query="SELECT c FROM Client c WHERE c.id = :id"),
    @NamedQuery(name="Client.findAllByLastName", query="SELECT c FROM Client c WHERE c.lastname like :lastname ORDER BY c.lastname, c.firstname, c.id"),
    @NamedQuery(name="Client.getSession", query="SELECT s FROM Client c INNER JOIN c.session s WHERE c.id = :id")})
public class Client {
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	@Column(nullable=false)
	private String lastname;
	
	@Column(nullable=false)
	private String firstname;
	
	@Column(nullable=false)
	private String address;
	
	@Column(nullable=false)
	private String phone;
	
	@Column
	private String email;
	
	@ManyToOne
	@JoinColumn(name="session_id", nullable=false)
	private Session session;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

}
